import axios from 'axios'
import cookie from '../../assets/js/cookie'
/* 项目的service */
export default {

	//开单
	doOpenOrder(studentFileList,checkOrderList,imgList) {
		var reqData={
			checkItemList:checkOrderList,
			studentList:studentFileList,
			imgList:imgList,
		};
		reqData = cookie.setOpenInfoToData(reqData);

		if (cookie.get(cookie.key.openOrderStuFileId)) {
				reqData.openOrderStuFileId = cookie.get(cookie.key.openOrderStuFileId);
				reqData.openOrderStuUserId = cookie.get(cookie.key.openOrderStuUserId);
				reqData.openOrderStuName = cookie.get(cookie.key.openOrderStuName);
				reqData.openOrderStuCellphone = cookie.get(cookie.key.openOrderStuCellphone);
		}

		return axios({
			url:'/thridclassroom/open_order/doOpenOrder',
			method: 'post',
			data: reqData,
		});
	},
	//开单
	doUpdateOpenOrder(id,studentFileList,checkOrderList,imgList) {
		var reqData={
			id:id,
			checkItemList:checkOrderList,
			studentList:studentFileList,
			imgList:imgList,
		};
		reqData = cookie.setOpenInfoToData(reqData);
		return axios({
			url:'/thridclassroom/open_order/doUpdateOpenOrder',
			method: 'post',
			data: reqData,
		});
	},
	//获取开单的分页数据
	getOpenOrderPage(page,param) {
		var reqData={  
			page: page,
			params: param, //+'?'+ this.$qs.stringify(reqData)
			rows: 10
		};
		return axios({
			url:'/thridclassroom/open_order/page',
			method: 'post',
			data: reqData,
		});
	},
	//获取考核单的分页数据
	getOpenOrder(id) {
		return axios.get('/thridclassroom/open_order/orderInfo/'+id);
	},
	//撤回
	doBackState(openOrderId,reason) {
		var reqData={
            　　　 id:openOrderId,
            　　　 reason:reason,
		}
		reqData = cookie.setOpenInfoToData(reqData);

		let param = new URLSearchParams();
		for (var key in reqData) {
			param.append(key, reqData[key])
		}

	    return axios({
			url:'/thridclassroom/open_order/doBackState',
			method: 'post',
			data: param,
			headers:{
				'Content-Type':'application/x-www-form-urlencoded'
			}
		});

	},
/* 		"recallType", value = "撤消撤回类型，撤消：1，撤回：2",
		 "cancelWay", value = "撤消渠道，学生申诉撤消：1，老师主动撤消：2", */
	doBackCheckOrder(id,reason,recallType,cancelWay) {
		var reqData={
            　　　 id:id,
            　　　 reason:reason,
            　　　 recallType:recallType,
            　　　 cancelWay:cancelWay,
		}
		var user = cookie.getLoginUserData();
		reqData.cancelUserId=user.userId;
		reqData.cancelFileId=user.userFileId;
		reqData.cancelCellphone=user.operCellphone;
		reqData.cancelName=user.userName;
		let param = new URLSearchParams();
		for (var key in reqData) {
			param.append(key, reqData[key])
		}

	    return axios({
			url:'/thridclassroom/check_order/doBackState',
			method: 'post',
			data: param,
			headers:{
				'Content-Type':'application/x-www-form-urlencoded'
			}
		});
	},
	//获取考核单的分页数据
	getCheckOrderPage(page,param) {
		var reqData={  
			page: page,
			params: param, //+'?'+ this.$qs.stringify(reqData)
			rows: 10
		};
		return axios({
			url:'/thridclassroom/check_order/page',
			method: 'post',
			data: reqData,
		});
	},
	//获取考核单的分页数据
	getCheckOrder(id,params) {
		return axios.get('/thridclassroom/check_order/'+id,{
            　　params:params
        });
	},

 }